<template>
  <div>
   <div> 
     <ul>
      <li v-for="(item,index) in arr" :key="index">{{item}}<button @click="btn(index)">{{text}}</button>
      </li>
    </ul>
    <button @click="btn1">点击生成</button>
  </div>
  </div>
</template>

<script>
export default {
   data(){
     return {
       text:'删除',
       arr:[1,2,3]
     }
   },
   methods:{
     btn(index){
       this.arr.splice(index,1)
     },
     btn1(){
       this.arr.push(Math.floor(Math.random()*20 +1))
     }
   }
}
</script>

<style>
 
</style>